package cn.doitedu.visualiz.platform.controller;


import cn.doitedu.visualiz.platform.service.FunnelAnalysisService;
import cn.doitedu.visualiz.platform.vo.FunnelParams;
import cn.doitedu.visualiz.platform.vo.FunnelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.*;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;

@RestController
public class FunnelAnalysisController {

    @Autowired
    FunnelAnalysisService funnelAnalysisService;


    @RequestMapping(method = RequestMethod.POST,value = "/api/v1/funnel")
    public FunnelVo queryFunnel(@RequestBody FunnelParams funnelParams) throws SQLException {

        System.out.println(funnelParams);

        // 解析

        // 调用service，拼接sql，并查询
        HashMap<String, String> resultMap = funnelAnalysisService.funnelAnalysis(funnelParams);

        // 将service返回的结果，封装成页面所需要的结构，进行返回即可
        FunnelVo vo = new FunnelVo();
        vo.setCompleteStep(resultMap);
        vo.setFunnelName(funnelParams.getFunnelName());
        vo.setStatus("200");

        return vo;

    }
}
